﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--
 * 
 * File Name: fck_postlink.html
 * 	Postlink Plugin.
 * 
 * File Authors:
 * 		buti_oxa
-->
<html>
	<head>
		<title>PostVideo Dialog</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta content="noindex, nofollow" name="robots">
		<script language="javascript">

var oEditor = window.parent.InnerDialogLoaded() ;
var FCKPostvideo = oEditor.FCKPostvideo ;

window.onload = function ()
{
	// Show the "Ok" button.
	window.parent.SetOkButton( true ) ;	
}


function Ok()
{
	var sUrl = document.getElementById('txtID').value ;
	var	sHtml = '';;

	
	if ( sUrl.length == 0 )	{
		alert( "You forgot to paste URL." ) ;
		return false ;
	}

	if ( sUrl.match(/youtube/)) {

		var rgMatch = sUrl.match(/v[\/\=]([a-zA-Z0-9\-_]*)/);		// www.youtube.com/v/DDOgYw5-pNs

		if (rgMatch) 
			{
			var vidNumber = rgMatch[1];
			if (document.getElementById('thumb').checked)
				{		
//				sHtml = '<a href="http://www.youtube.com/watch?v=' + vidNumber +
				sHtml = '<a href="/view_video.php?v=' + vidNumber +
					'"><img src="http://img.youtube.com/vi/' + vidNumber + '/2.jpg" alt="video" /></a>';
				}
			else
				{
				sHtml = '<embed src="http://www.youtube.com/v/' + vidNumber +
						'" width="425" height="350" type="application/x-shockwave-flash" ' +
						'wmode="transparent"></embed>';
				}				
			}
	}

	else if ( sUrl.match(/video\.google/)) {

		var rgMatch = sUrl.match(/docid=\-([0-9]*)/);		// http://video.google.com/videoplay?docid=-3964409909426702322

		if (rgMatch) 
			{
			var vidNumber = rgMatch[1];
			sHtml = '<embed src="http://video.google.com/googleplayer.swf?docId=-' + vidNumber +
					'" width="400" height="326" type="application/x-shockwave-flash"></embed>';
			}
	}

	else if ( sUrl.match(/myspace\.com/)) {

		var rgMatch = sUrl.match(/videoid=([0-9]*)/);		// http://vids.myspace.com/index.cfm?fuseaction=vids.individual&videoid=2020420392

		if (rgMatch) 
			{
			var vidNumber = rgMatch[1];
			sHtml = '<embed src="http://lads.myspace.com/videos/vplayer.swf" flashvars="m=' + vidNumber +
					'&type=video" width="430" height="346" type="application/x-shockwave-flash"></embed>';
			}
	}

	if (sHtml == '') 
		sHtml = '<a href="' + sUrl + '">' + sUrl + '</a>';

	oEditor.FCK.InsertHtml( sHtml ) ;
	return true ;
}

		</script>
	</head>
	
	<body scroll="no" style="OVERFLOW: hidden">
		<table height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0">
			<tr>
				<td>
					<table cellSpacing="0" cellPadding="0" align="center" border="0">
						<tr>
							<td align="center">
								<div style="margin-bottom: 6px">Input video's URL</div>
								<input id="txtID" type="text" size=40>
								<div style="font-size : 90%; text-align:left; margin-top: 6px">
									For example: http://www.youtube.com/watch?v=DDOgYw5-pNs
								</div>
								<div style="ext-align:left; margin-top: 6px">
									<input type=checkbox id=thumb> Thumbnail only
								</div>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</body>
</html>

